class Listener{

    public funs:Map<string,Array<Function>> = new Map<string,Array<Function>>()

    public on (name:string,fun:Function) {
        if(this.funs.has(name)) {
            this.funs.get(name)?.push(fun)
        }else {
            this.funs.set(name,[fun])
        }
    }

    public emit(name:string) {
        if(this.funs.has(name)) {
           const  x = this.funs.get(name)
           x?.forEach(x => {
            x()
           })
        }
    }
}
const lisener = new Listener()
export default lisener